package com.d4peng.test.jna;

import com.sun.jna.Library;
import com.sun.jna.Native;

import java.io.File;

/**
 * JNA:Jna方式的简单实现初体验
 * 该操作是windows平台下编译的动态库
 *
 * @author d4peng
 * @date 2021-11-25
 */

public class JnaDemo1 {
    interface Sum extends Library {
        int sum(int x, int y);
    }

    public static void main(String[] args) {
        String path = new File("").getAbsoluteFile().getPath() + "\\src\\main\\java\\com\\d4peng\\test\\jna\\c\\struct.dll";
        Sum sum = (Sum) Native.loadLibrary(path, Sum.class);
        System.out.println(sum.sum(4, 2));
    }
}
